package com.bwie.controller;

import com.bwie.common.domain.User;
import com.bwie.common.domain.request.LoginRequest;
import com.bwie.common.domain.response.LoginResponse;
import com.bwie.common.result.Result;
import com.bwie.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @className: LoginController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘茂锴
 * @date: 2025/10/13 10:33
 */
@RestController
@RequestMapping("/login")
@CrossOrigin
public class LoginController {
    @Autowired
    private LoginService loginService;
    //发送短信验证码
    @GetMapping("/phoneCode/{phone}")
    public Result phoneCode(@PathVariable("phone")String phone){
        loginService.phoneCode(phone);
        return Result.success();
    }
    //登录
    @PostMapping("/loginUser")
    public Result loginUser(@RequestBody @Valid LoginRequest loginRequest){
        LoginResponse loginResponse=loginService.loginUser(loginRequest);
        return Result.success(loginResponse);
    }
}
